package robocup.testing;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.util.LinkedList;

import robocup.component.geometry.Circle;
import robocup.component.geometry.CircleSegment;
import robocup.component.geometry.LineSegment;
import robocup.component.geometry.StraightLine;
import robocup.component.geometry.Vektor;
import robocup.component.util.Randoms;


/**
 * @author Thomas Karbe
 *
 * This class is an example for the usage of the GraphicalTestFrame. It shows the intersection points between a Circle, a CircleSegment, a LineSegment and a StraightLine.
 */
public class ExampleTest
    extends GraphicalTestFrame {

  private final Circle c= Circle.getDummyInstance();
  private final Circle c2= Circle.getDummyInstance();
  private final CircleSegment cs= CircleSegment.getDummyInstance();
  private final LineSegment ls= LineSegment.getDummyInstance();
  private final StraightLine line= StraightLine.getDummyInstance();
  LinkedList<Vektor> list= new LinkedList<Vektor>();
  Randoms rand= Randoms.getInstance();

  @Override
  protected void nextSituation() {
    c.setCenter(rand.getRandomVektor(-4, 4, -4, 4));
    c.setRadius(1);
    c2.setCenter(rand.getRandomVektor(-4, 4, -4, 4));
    c2.setRadius(1);
    cs.copyCenter(rand.getRandomVektor(-4, 4, -4, 4));
    cs.setRadius(1);
    cs.setStartAngle(rand.getRandomDouble(-180, 180));
    cs.setEndAngle(rand.getRandomDouble(-180, 180));
    ls.copyPoint1(rand.getRandomVektor(-4, 4, -4, 4));
    ls.copyPoint2(rand.getRandomVektor(-4, 4, -4, 4));
    line.setStraightLine(rand.getRandomVektor(-4, 4, -4, 4), rand.getRandomDouble(-180, 180));
    list.clear();
    c.addIntersectionPointsToList(c2, list);
//    c.addIntersectionPointsToList(cs, list);
//    c.addIntersectionPointsToList(ls, list);
//    c.addIntersectionPointsToList(line, list);
//    cs.addIntersectionPointsToList(ls, list);
//    cs.addIntersectionPointsToList(line, list);
//    ls.addIntersectionPointToList(line, list);
  }

  @Override
  protected void nextCycle() {
    cs.setRadius(cs.getRadius()+1);
    c.setRadius(c.getRadius()+1);
    c2.setRadius(c2.getRadius()+1);
    list.clear();
    c.addIntersectionPointsToList(c2, list);
//    c.addIntersectionPointsToList(cs, list);
//    c.addIntersectionPointsToList(ls, list);
//    c.addIntersectionPointsToList(line, list);
//    cs.addIntersectionPointsToList(ls, list);
//    cs.addIntersectionPointsToList(line, list);
//    ls.addIntersectionPointToList(line, list);
  }

  @Override
  protected void paintSituation(Graphics g) {
    g.setColor(Color.BLUE);
    draw(g,c);
    g.setColor(Color.BLUE);
    draw(g,c2);
//    g.setColor(Color.green);
//    draw(g,cs);
//    g.setColor(Color.red);
//    draw(g,ls);
//    g.setColor(Color.CYAN);
//    draw(g,line);
    g.setColor(Color.ORANGE);
    draw(g,list);
  }

  /**
   * @param args
   */
  public static void main(String[] args) {
    new ExampleTest(new Dimension(900,700), Vektor.CENTER, 1.5);
  }

  /**
   * 
   */
  public ExampleTest() {

    super();
  }

  /**
   * @param d
   * @param scale
   */
  public ExampleTest(
      Dimension d,
      double scale) {

    super(d, scale);
  }

  /**
   * @param d
   * @param center
   * @param scale
   */
  public ExampleTest(
      Dimension d,
      Vektor center,
      double scale) {

    super(d, center, scale);
  }

  /**
   * @param d
   * @param center
   */
  public ExampleTest(
      Dimension d,
      Vektor center) {

    super(d, center);
  }

  /**
   * @param d
   */
  public ExampleTest(
      Dimension d) {

    super(d);
  }

  /**
   * @param scale
   */
  public ExampleTest(
      double scale) {

    super(scale);
  }

  /**
   * @param center
   * @param scale
   */
  public ExampleTest(
      Vektor center,
      double scale) {

    super(center, scale);
  }

  /**
   * @param center
   */
  public ExampleTest(
      Vektor center) {

    super(center);
  }

}
